【07】tensorflow 細看存檔:save pb 篇

您所在的位置:网站首页 keras save pb 【07】tensorflow 細看存檔:save pb 篇

【07】tensorflow 細看存檔:save pb 篇

2023-12-15 17:18| 来源: 网络整理| 查看: 265

大家好, 我想把 .pb 轉成 .pbtxt, 程式碼如下:

import tensorflow as tf from tensorflow.python.platform import gfile def convert_pb_to_pbtxt(filename): with tf.io.gfile.GFile(filename, 'rb') as f: graph_def = tf.compat.v1.GraphDef() graph_def.ParseFromString(f.read()) tf.import_graph_def(graph_def, name='') tf.train.write_graph(graph_def, './', 'protobuf.pbtxt', as_text=True) return filename = 'efficientnet-lite4-11.pb' convert_pb_to_pbtxt(filename);

運行時遇到如下的問題:

D:\download\onnx\onnx_2_pb\efficientNet>python convert_to_bptxt.py 2021-02-22 11:44:21.746474: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found 2021-02-22 11:44:21.748660: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 501, in _import_graph_def_internal graph._c_graph, serialized, options) # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: Node 'Softmax:0': Node name contains invalid characters

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "convert_to_bptxt.py", line 15, in convert_pb_to_pbtxt(filepath); File "convert_to_bptxt.py", line 9, in convert_pb_to_pbtxt tf.import_graph_def(graph_def, name='') File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func return func(*args, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 405, in import_graph_def producer_op_list=producer_op_list) File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\importer.py", line 505, in _import_graph_def_internal raise ValueError(str(e)) ValueError: Node 'Softmax:0': Node name contains invalid characters

D:\download\onnx\onnx_2_pb\efficientNet> 主要是:ValueError: Node 'Softmax:0': Node name contains invalid characters 我的python 版本是: D:\download\onnx\onnx_2_pb\efficientNet>python --version Python 3.7.8

tensorflow 版本是: D:\download\onnx\onnx_2_pb\efficientNet>pip show tensorflow Name: tensorflow Version: 1.15.0 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ Author: Google Inc. Author-email: [email protected] License: Apache 2.0 Location: c:\users\user\appdata\local\programs\python\python37\lib\site-packages Requires: grpcio, google-pasta, opt-einsum, astor, termcolor, wrapt, gast, protobuf, numpy, absl-py, six, keras-applications, tensorflow-estimator, tensorboard, wheel, keras-preprocessing Required-by:

想請教 這是什麼問題呢? 有什麼解決的方法呢?

Regards,



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3